package com.knight.spring.framework.aop.adapter;

import com.knight.spring.framework.aop.intercept.KnightMethodInvocation;

import java.lang.reflect.Method;

public class KnightReturningAdviceInterceptor extends KnightAbstractAspectAdvice {

    public KnightReturningAdviceInterceptor(Method aspectMethod, Object aspectTarget) {
        super(aspectMethod, aspectTarget);
    }

    private void afterReturning(KnightMethodInvocation invocation, Object returnVal) throws Throwable {
        super.invokeAdviceMethod(invocation,returnVal,null);
    }


    @Override
    public Object invoke(KnightMethodInvocation invocation) throws Throwable {
        Object returnVal = invocation.proceed();
        this.afterReturning(invocation,returnVal);
        return returnVal;
    }
}
